package sanshui.system.trade.util;

import sanshui.system.trade.pojo.StockInfoVo;

import java.util.ArrayList;
import java.util.List;

public class StockFilterUtil {
    public static List<StockInfoVo> codeNotIn(List<StockInfoVo> target, List<String> filter){
        List<StockInfoVo> rsl = new ArrayList<>();
        for (StockInfoVo item : target) {
            boolean exit = false;
            String tsCode = item.getTsCode();
            for (String f : filter) {
                if (tsCode.contains(f)){
                    exit = true;
                    break;
                }
            }
            if (!exit){
                rsl.add(item);
            }
        }
        return rsl;
    }

    public static List<StockInfoVo> codeIn(List<StockInfoVo> target, List<String> filter){
        List<StockInfoVo> rsl = new ArrayList<>();
        for (StockInfoVo item : target) {
            boolean exit = false;
            String tsCode = item.getTsCode();
            for (String f : filter) {
                if (tsCode.contains(f)){
                    exit = true;
                    break;
                }
            }
            if (exit){
                rsl.add(item);
            }
        }
        return rsl;
    }

    public static List<StockInfoVo> nameNotIn(List<StockInfoVo> target, List<String> filter){
        List<StockInfoVo> rsl = new ArrayList<>();
        for (StockInfoVo item : target) {
            boolean exit = false;
            String tsName = item.getTsName();
            for (String f : filter) {
                if (tsName.contains(f)){
                    exit = true;
                    break;
                }
            }
            if (!exit){
                rsl.add(item);
            }
        }
        return rsl;
    }
}
